﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;

using Willson.JsbManager.Bll;
using Willson.JsbManager.BllEntity;
using Willson.JsbManager.Comm;

namespace Willson.JsbManager.UI
{
    public partial class XTCompanyCjhSumForm : Willson.JsbManager.UI.BaseForm
    {
        public XTCompanyCjhSumForm()
        {
            InitializeComponent();
        }

        private void XTCompanyCjhSumForm_Load(object sender, EventArgs e)
        {
            //List<string> list = BLLFactory<BLLComm>.Instance.GetEmployeeList();

            //IEnumerator<string> ator = list.GetEnumerator();

            //while (ator.MoveNext())
            //{
            //    cbx_employee.Items.Add(ator.Current.ToString());
            //}
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(comboBox_year.Text))
            {
                MessageUtil.ShowWarning("请选择[年]");
                return;
            }

            if (string.IsNullOrEmpty(comboBox_jd.Text))
            {
                MessageUtil.ShowWarning("请选择[季度]");
                return;
            }

            IEnumerator<BECompanyCjhAllInfo> ator = BLLFactory<BLLCompanyCjhSum>.Instance.GetCompanyCjhAllInfo(Convert.ToInt32(comboBox_year.Text), Convert.ToInt32(comboBox_jd.Text)).GetEnumerator();

            PrintDataSet ds = new PrintDataSet();


            while (ator.MoveNext())
            {
                DataRow objRow = ds.Tables["CompanyCjhAllInfo"].NewRow();

                objRow["Company_name"] = ator.Current.Company_name;
                objRow["Company_address"] = ator.Current.Company_address;
                objRow["Company_tel"] = ator.Current.Company_tel;
                objRow["Jd_jh"] = ator.Current.Jd_jh;
                objRow["Jd_ysl"] = ator.Current.Jd_ysl;
                objRow["Jd_cjh"] = ator.Current.Jd_cjh;
                objRow["Jd_old_jh"] = ator.Current.Jd_old_jh;
                objRow["Jd_jh_begin"] = ator.Current.Jd_jh_begin;

                ds.Tables["CompanyCjhAllInfo"].Rows.Add(objRow);
                
            }

            List<ReportParameter> listPara = new List<ReportParameter>();

            ReportParameter para = new ReportParameter("Title", string.Format("{0}年{1}季度超计划用水信息表", comboBox_year.Text, comboBox_jd.Text));

            listPara.Add(para);

            XTPrintViewForm form = new XTPrintViewForm();
            form.Bind(ds, "CompanyCjhAllInfo", "Willson.JsbManager.UI.CompanyCjhAllInfo.rdlc", "PrintDataSet_CompanyCjhAllInfo", listPara);
            form.ShowDialog();


        }

        private void button2_Click(object sender, EventArgs e)
        {
            string ls_jd = string.Empty;

            if (String.IsNullOrEmpty(comboBox_year.Text))
            {
                MessageUtil.ShowWarning("请选择[年]");
                return;
            }

            if (string.IsNullOrEmpty(comboBox_jd.Text))
            {
                MessageUtil.ShowWarning("请选择[季度]");
                return;
            }

            if (comboBox_jd.Text == "1") ls_jd = "第一季度";
            if (comboBox_jd.Text == "2") ls_jd = "第二季度";
            if (comboBox_jd.Text == "3") ls_jd = "第三季度";
            if (comboBox_jd.Text == "4") ls_jd = "第四季度";
            

            IEnumerator<BECompanyCjhLetter> ator = BLLFactory<BLLCompanyCjhSum>.Instance.GetCompanyCjhLetterInfo(Convert.ToInt32(comboBox_year.Text), Convert.ToInt32(comboBox_jd.Text)).GetEnumerator();

            PrintDataSet ds = new PrintDataSet();

            while (ator.MoveNext())
            {
                DataRow objRow = ds.Tables["CompanyCjhLetter"].NewRow();

                objRow["ht_code_1"] = ator.Current.ht_code_1;
                objRow["ht_code_2"] = ator.Current.ht_code_2;
                objRow["ht_code_3"] = ator.Current.ht_code_3;
                objRow["ht_code_4"] = ator.Current.ht_code_4;
                objRow["ht_code_5"] = ator.Current.ht_code_5;
                objRow["ht_code_6"] = ator.Current.ht_code_6;
                objRow["jd_jh"] = ator.Current.jd_jh;
                objRow["jd_ysl"] = ator.Current.jd_ysl;
                objRow["sl_1"] = ator.Current.sl_1;
                objRow["sl_2"] = ator.Current.sl_2;
                objRow["sl_3"] = ator.Current.sl_3;
                objRow["bfb_1"] = ator.Current.bfb_1;
                objRow["bfb_2"] = ator.Current.bfb_2;
                objRow["bfb_3"] = ator.Current.bfb_3;
                objRow["bs_1"] = ator.Current.bs_1;
                objRow["bs_2"] = ator.Current.bs_2;
                objRow["bs_3"] = ator.Current.bs_3;
                objRow["dj_1"] = ator.Current.dj_1;
                objRow["dj_2"] = ator.Current.dj_2;
                objRow["dj_3"] = ator.Current.dj_3;
                objRow["money_1"] = ator.Current.money_1;
                objRow["money_2"] = ator.Current.money_2;
                objRow["money_3"] = ator.Current.money_3;
                objRow["money_all"] = ator.Current.money_all;
                objRow["CompanyName"] = ator.Current.company_name;

                ds.Tables["CompanyCjhLetter"].Rows.Add(objRow);

            }

            XTPrintViewForm form = new XTPrintViewForm();

            List<ReportParameter> listPara = new List<ReportParameter>();

            ReportParameter para1 = new ReportParameter("YearJd", string.Format("{0}年{1}", comboBox_year.Text, ls_jd));
            ReportParameter para2 = new ReportParameter("Date", System.DateTime.Today.Date.ToShortDateString());

            listPara.Add(para1);
            listPara.Add(para2);

            form.Bind(ds, "CompanyCjhLetter", "Willson.JsbManager.UI.CompanyCjhLetter.rdlc", "PrintDataSet_CompanyCjhLetter", listPara);
            form.ShowDialog();


        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(comboBox_year.Text))
            {
                MessageUtil.ShowWarning("请选择[年]");
                return;
            }

            if (string.IsNullOrEmpty(comboBox_jd.Text))
            {
                MessageUtil.ShowWarning("请选择[季度]");
                return;
            }

            PrintDataSet ds = new PrintDataSet();

            IEnumerator<BECompanyLetterPrint> ator = BLLFactory<BLLCompanyCjhSum>.Instance.GetCompanyLetterPrintInfoList(Convert.ToInt32(comboBox_year.Text), Convert.ToInt32(comboBox_jd.Text)).GetEnumerator();

            DataRow objRow;

            while (ator.MoveNext())
            {
                objRow = ds.Tables["CompanyLetterPrint"].NewRow();

                objRow["PostCode"] = ator.Current.m_PostCode;
                objRow["Address"] = ator.Current.m_Address;
                objRow["Sjr"] = ator.Current.m_Sjr;

                ds.Tables["CompanyLetterPrint"].Rows.Add(objRow);
            }

            XTPrintViewForm form = new XTPrintViewForm();
            form.Bind(ds, "CompanyLetterPrint", "Willson.JsbManager.UI.CompanyLetterPrint.rdlc", "PrintDataSet_CompanyLetterPrint", null);
            form.ShowDialog();

        }

        private void button4_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(comboBox_year.Text))
            {
                MessageUtil.ShowWarning("请选择[年]");
                return;
            }

            if (string.IsNullOrEmpty(comboBox_jd.Text))
            {
                MessageUtil.ShowWarning("请选择[季度]");
                return;
            }

            DeleGatePrintForm form = new DeleGatePrintForm(Convert.ToInt32(comboBox_year.Text), Convert.ToInt32(comboBox_jd.Text));

            form.ShowDialog();
        }
    }
}
